<?php //pack11class

class ObjectsListHeader extends Module {

    public $linecolspan;
    public static $sortableProperties=array();

	public function setup() {

        $this->linecolspan=3+count(ObjectsListNavigation::getColumns());

        //$this->addChild(new TablePropertiesHeader);
        $this->addChild(new TablePropertiesShortHeader);

        $sortableProperties=ObjectsListNavigation::getColumns();
        usort($sortableProperties,array(get_class($this),"columnPosition"));
        self::$sortableProperties=$sortableProperties;

        $columnsCount=0;

        foreach($sortableProperties as $property) {
            $column=new ObjectsListHeaderSortable;
            //$column->setBody($property->label);
            $column->label=$property->label;
            $column->property=$property;
            $column->draw();
            $this->addChild($column);
            $columnsCount++;
            if($columnsCount>2) break;
        }

        $priceHeader=new ObjectsListHeaderPrice;
        $priceHeader->property=PropertiesManager::getProperty("cost");
        $priceHeader->draw();
        $this->addChild($priceHeader);
    }

    private static function columnPosition(Property $a, Property $b) {
        return ($a->id>$b->id);
    }

}
?>
